﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="RestaurantList.aspx.vb" Inherits="WSCC_GlutenfreeKent.Restaurants" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Menu ID="Menu1" runat="server">
        <Items>
            <asp:MenuItem NavigateUrl="~/RestaurantPages/AddRestaurant.aspx" Text="Add a Restaurant" 
                Value="Add a Restaurant"></asp:MenuItem>
        </Items>
    </asp:Menu>
    <br/>
    <asp:TextBox ID="tb_Search" runat="server" /> &nbsp;
    <asp:ImageButton ID="btn_Search" ImageURL="~/Pictures/SearchButton.jpg" 
        runat="server" style="top: 5px; position: relative; height:20px; width:50px; left: 0px;"
         OnClick="btnSearch_Click" /> &nbsp;
    <asp:ImageButton ID="btn_ClearSearch" ImageURL="~/Pictures/clearButton.png" runat="server" style="top: 5px; position: relative; height:20px; width:50px"
     OnClick="btnClearSearch_Click"  /> 
    <br />
    Click a tag below to view the tagged restaurants<br />
    <asp:Repeater ID="Repeater1" runat="server" DataSourceID="TagsDataSource">
    <ItemTemplate> 
    <a href="RestaurantList.aspx?Tag=<%# Eval("Tag")%>">
    <%# Eval("Tag")%>&nbsp
    </a>
    </ItemTemplate>
    
    </asp:Repeater>
<br />
<asp:SqlDataSource ID="TagsDataSource" runat="server" 
    ConnectionString="<%$ ConnectionStrings:ConnectionStringRestaurants %>" 
    ProviderName="<%$ ConnectionStrings:ConnectionStringRestaurants.ProviderName %>" 
    SelectCommand="SELECT [Tag] FROM [Tags]"></asp:SqlDataSource>
<br />
    <p>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" 
            DataSourceID="RestaurantsDB" AllowSorting="True" Height="274px" 
            Width="916px">
            <SortedAscendingHeaderStyle CssClass="sortasc" />
            <SortedDescendingHeaderStyle CssClass="sortdesc" />
            <Columns>
                <asp:ImageField DataImageUrlField="Photo" HeaderText="Photo" 
                    SortExpression="RestaurantName">
                    <ControlStyle CssClass="restaurantPhoto" Height="200px" Width="200px" />
                </asp:ImageField>
                <asp:HyperLinkField DataNavigateUrlFields="URL" 
                    DataNavigateUrlFormatString="{0}" DataTextField="RestaurantName" 
                    HeaderText="Restaurant Name" SortExpression="RestaurantName" />
                <asp:HyperLinkField DataNavigateUrlFields="PostCode" 
                    DataNavigateUrlFormatString="http://maps.google.co.uk/maps?q={0}" 
                    DataTextField="PostCode" HeaderText="Location" SortExpression="PostCode" />
                <asp:BoundField DataField="LastReviewDate" HeaderText="LastReviewDate" 
                    SortExpression="LastReviewDate" DataFormatString="{0:d}" />
                <asp:BoundField DataField="PriceBracket" HeaderText="PriceBracket" 
                    SortExpression="PriceBracket" />
                <asp:HyperLinkField DataNavigateUrlFields="ID" 
                    DataNavigateUrlFormatString="details.aspx?ID={0}" 
                    HeaderText="Details" Text="Detail" SortExpression="RestaurantName"/>
                <asp:HyperLinkField DataNavigateUrlFields="Menu" HeaderText="Menu" 
                    Text="Menu" SortExpression="Menu"/>
                <asp:TemplateField HeaderText="Rating" SortExpression="Rating">
                <ItemTemplate>
             <%-- data binding to Rating field in the database--%>
                <%# getRating(Eval("Rating"))%>

                </ItemTemplate>
                
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="RestaurantsDB" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionStringRestaurants %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionStringRestaurants.ProviderName %>" 
            CancelSelectOnNullParameter="false">
        <FilterParameters>
        <asp:ControlParameter Name="RestaurantName" ControlID="tb_Search" PropertyName="Text" />
        </FilterParameters>
        
            <SelectParameters>
                <asp:QueryStringParameter Name="Tag" QueryStringField="Tag" Type="String" />
            </SelectParameters>
        
        </asp:SqlDataSource>
    </p>
<p>
        &nbsp;</p>
    </asp:Content>
